//校验审批/抄送人员添加
const resultList: boolean[] = [];
/**
 * 遍历流程图每个节点
 */
function traverseFlowGraphCheckPersons(currentList: FlowPathTemplateApi.FlowGraph | undefined) {
  if (!currentList) {
    return;
  }
  const flowType = currentList.flowType;
  if (flowType === 1) {
    if (!approveTypeCheckPersons(currentList)) {
      return;
    }
  }
  if (!currentList.nextList) {
    return;
  }
  traverseFlowGraphCheckPersons(currentList.nextList[0]);
}

/**
 * 检查审批人是否都添加人员
 * @param currentList 当前节点
 * @returns 执行结果 true 执行完成 false 遇到问题执行失败
 */
function approveTypeCheckPersons(currentList: FlowPathTemplateApi.FlowGraph): boolean {
  if (!currentList.approverDto) {
    return false;
  }

  if (
    !currentList.approverDto.approverVsetList ||
    currentList.approverDto.approverVsetList.length === 0
  ) {
    resultList.push(false);
  } else {
    resultList.push(true);
  }

  return true;
}
export { traverseFlowGraphCheckPersons, resultList };
